<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateTableKmsClientAuth extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('kms_clients_auth', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger("clientId")->default(0)->comment("kms_clients.id");
            $table->unsignedTinyInteger("type")->default(0)->comment("授权类型  1 - 飞书userId 2 - 飞书部门");
            $table->string("targetId", 64)->default("")->comment("授权类型标识");

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->unsignedInteger('isDeleted')->default(0)->comment('是否删除 0 - 正常 1 - 已删除');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = 'kms小程序授权表';
            $table->index(["clientId", "isDeleted"], 'idx_clientId_isDeleted');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('kms_clients_auth');
    }
}
